package cn.edu.zime.bigdata.dao.mapper;

import cn.edu.zime.bigdata.dao.model.CountValue;
import cn.edu.zime.bigdata.dao.model.Student;
import cn.edu.zime.bigdata.dao.model.Teacher;
import cn.edu.zime.bigdata.dao.model.Teachers;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {
    @Insert("insert into teachers(id, name, genda, position, subject, birthdate,age) values(#{id},#{name},#{genda},#{position},#{subject}, #{birthdate}, #{age})")
    public int insertTeacher(Teacher u);

    @Select("select * from teachers")
    public List<Teacher> selectAllTeachers();

    @Select("select * from teachers where id like CONCAT('%', #{id}, '%') or name like CONCAT('%', #{name}, '%')")
    public List<Teacher> selectTeachers(String id, String name);

    @Update("update teachers set name=#{name}, genda=#{genda}, position=#{position}, subject=#{subject}, birthdate=#{birthdate}, age=#{age} where id=#{id}")
    public int updateTeacher(Teacher teacher);

    @Delete("delete from teachers where id = #{id}")
    public int deleteTeacher(String id);

    @Select("SELECT  CONCAT(COUNT(*)) as gs  , position FROM teachers  GROUP BY position")
    public List<Teachers> selectupTeachers();

    @Select("SELECT  CONCAT(COUNT(*)) as gs  , subject FROM teachers  GROUP BY subject")
    public List<Teachers> selectupallTeachers();
}